package ace.module.captcha.sms.sdk.core.feign.impl;

import ace.cmp.core.model.R;
import ace.cmp.openfeign.security.oauth2.core.config.FeignInternalServerOauth2SecurityConfig;
import ace.module.captcha.sms.api.model.dto.CaptchaSmsItemDto;
import ace.module.captcha.sms.sdk.core.constant.SdkConstant;
import ace.module.captcha.sms.sdk.core.feign.CaptchaSmsItemFeignApi;
import ace.module.common.api.annotation.ApiRemoteProxyPriority;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 验证码 rpc feign.
 *
 * @author Caspar
 */
@FeignClient(
    name = "${spring.cloud.openfeign.client.config.captchaSmsItemFeign.name:" + SdkConstant.FEIGN_SERVICE_NAME + "}",
    contextId = "captchaSmsItemFeign",
    path = CaptchaSmsItemFeign.PATH,
    configuration = FeignInternalServerOauth2SecurityConfig.class,
    primary = false
)
@ApiRemoteProxyPriority
public interface CaptchaSmsItemFeign extends CaptchaSmsItemFeignApi {

  String PATH = "${spring.cloud.openfeign.client.config.captchaSmsItemFeign.path:/captcha-sms/captcha-sms-item/rpc}";

  @Operation(summary = "获取有效的验证码数据", description = "data=验证码数据")
  @GetMapping(path = "/getByCaptchaSmsAppIdAndPhone")
  R<CaptchaSmsItemDto> getByCaptchaSmsAppIdAndPhone(
      @Valid @NotNull @RequestParam("captchaSmsAppId") Long captchaSmsAppId,
      @Valid @NotBlank @RequestParam("phone") String phone);
}